const { defineConfig } = require('@vue/cli-service')

module.exports = defineConfig({
  transpileDependencies: true,

  // 开发服务器配置
  devServer: {
    port: 8083,
    open: true,
    client: {
      overlay: {
        errors: true,
        warnings: false,
        runtimeErrors: (error) => {
          // 过滤掉ResizeObserver错误
          const ignoreErrors = [
            'ResizeObserver loop limit exceeded',
            'ResizeObserver loop completed with undelivered notifications'
          ]
          return !ignoreErrors.some(ignoreError =>
            error.message && error.message.includes(ignoreError)
          )
        }
      }
    },
    proxy: {
      '/api': {
        target: 'http://localhost:8081',
        changeOrigin: true,
        pathRewrite: {
          '^/api': '/api'
        }
      }
    }
  },

  // CSS 配置
  css: {
    loaderOptions: {
      scss: {
        // 移除全局导入，避免循环引用
      }
    }
  },

  // 路径别名配置
  configureWebpack: {
    resolve: {
      alias: {
        '@': require('path').resolve(__dirname, 'src')
      }
    }
  },

  // 生产环境配置
  productionSourceMap: false,

  // 公共路径
  publicPath: process.env.NODE_ENV === 'production' ? './' : '/'
})
